/*
 * @Author: dadadaXU 1413107032@qq.com
 * @Date: 2025-01-16 09:51:53
 * @LastEditors: dadadaXU 1413107032@qq.com
 * @LastEditTime: 2025-01-16 10:54:20
 * @FilePath: \leetcode\3095.或值至少-k-的最短子数组-i.cpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
/*
 * @lc app=leetcode.cn id=3095 lang=cpp
 *
 * [3095] 或值至少 K 的最短子数组 I
 * 区分子数组与子序列
 * - 子数组：必须连续
 * - 子序列：不要求元素在原数组中连续
 */

#include <algorithm>
#include <vector>
#include <iostream>

using namespace std;

// @lc code=start
class Solution
{
public:
    int minimumSubarrayLength(vector<int> &nums, int k)
    {
        int nums_len = nums.size();
        int subarrayLength;
        int num = 0;
        for (subarrayLength = 1; subarrayLength <= nums_len; subarrayLength++)
        {
            for (int i = 0; i < nums_len - subarrayLength + 1; i++)
            {
                for (int j = 0; j < subarrayLength; j++)
                    num |= nums[i + j];
                if (num >= k)
                    return subarrayLength;
                else
                    num = 0;
            }
        }

        return -1;
    }
};
// @lc code=end

int main(void)
{
    Solution solution;
    vector<int> nums = {12, 1, 8};
    int k = 0;

    cout << solution.minimumSubarrayLength(nums, k) << endl;

    return 0;
}